home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
443_01
/
doc
/
info
/
cncl.info-1
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
GNU Info File
|
1996-01-04
|
48.7 KB
|
1,678 lines
This is Info file cncl.info, produced by Makeinfo-1.63 from the input
file cncl.texi.
This file documents the use of CNCL, the Communication Networks Class
Library.
Copyright (C) 1993-1996, Communication Networks.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into other languages, under the above conditions for modified
versions.
File: cncl.info, Node: Top, Next: Introduction, Up: (DIR)
Introduction
************
This manual documents how to use the CNCL 1.4 classes in your
programs
* Menu:
* Introduction:: Introduction to the CNCL
* Basic Classes:: The Basic Classes of the CNCL Hierarchy
* Random Numbers:: Random Number Generators and Distributions
* Evaluation:: Statistical Evaluation in CNCL
* Container:: Container Classes
* Events:: Event Driven Simulation
* Arrays:: Arrays Classes
* Object Management:: Object Management
* Unix:: Unix Classes
* Misc:: Miscellaneous Classes
* EZD Interface:: EZD Interface Classes
* Fuzzy:: Fuzzy Logic Classes
* Persistent:: Persistent Classes
* Concept Index:: Index of Concepts
* Function Index:: Index of Functions
File: cncl.info, Node: Introduction, Next: Basic Classes, Prev: Top, Up: Top
Introduction to the CNCL
************************
CNCL is a C++ library created at Communication Networks, Aachen
University of Technology, Germany.
The main objective of this class library is to provide a common base
for all C++ applications created at Communication Networks. Therefore,
CNCL is both a class library featuring generic C++ classes as well as a
simulation library with strong points in random number generation,
statistics, and event driven simulation.
All globally visible classes and type definitions feature a "`CN'"
prepended to their name to avoid collision with other class libraries,
e.g. GNU libg++.
* Menu:
* Class Hierarchy:: CNCL Class Hierarchy
* Common Functions:: Common CNCL Member Functions
* CNgenclass:: CNgenclass Script to Generate Class Templates
* minmax:: min(), max() functions header file
File: cncl.info, Node: Class Hierarchy, Next: Common Functions, Up: Introduction
CNCL Class Hierarchy
====================
CNCL CNCL Static Members and Functions
CNObject Root of the CNCL Hierarchy
CNClass Class Description
CNParam Abstract Parameter Base Class
CNRNG Abstract Random Number Generator Base Class
CNACG Additive RNG
CNFiboG Fibonacci RNG
CNFileG Data File RNG
CNLCG Linear Congruence RNG
CNMLCG Multiple Linear Congruence RNG
CNTausG Tausworth RNG
CNRndInt Random Integers
CNRandom Abstract Random Distribution Base Class
CNBeta Beta Distribution
CNBinomial Binomial Distribution
CNDeterm Deterministic Distribution
CNDiracTab Distribution from Table
CNDiscUniform Discrete Uniform Distribution
CNErlang Erlang-k Distribution
CNGeometric Geometric Distributed Random Numbers
CNHyperExp HyperExp Distributed Random Numbers
CNHyperGeom HyperGeom Distributed Random Numbers
CNMDeterm Random Mix of Deterministic Distributions
CNNegExp Negative Exponential Distribution
CNNormal Normal Distribution
CNLogNormal LogNormal Distribution
CNRayleigh Rayleigh Distribution
CNRice Rice Distribution
CNPoisson Poisson Distribution
CNRandomMix Mix of Several `CNRandom' Distributions
CNTab Distribution from Table
CNInterTab Distribution from Table (Interpolated Values)
CNUniform Uniform Distribution
CNWeibull Weibull Distribution
CNStatistics Abstract Statistics Evaluation Base Class
CNMoments Evaluation of (Weighted) Moments
CNMomentsTime Evaluation of Time-Weighted Moments
CNLRE LRE Base Class
CNLREF Evaluation by LRE F(x)
CNLREG Evaluation by LRE G(x)
CNDLREF Evaluation by Discrete LRE F(x)
CNDLREG Evaluation by Discrete LRE G(x)
CNBatchMeans Evaluation by Batch Means
CNAVLTree AVL balanced binary search tree
CNAVLNode Node of AVL tree
CNSLList Single Linked List of Objects
CNDLList Doubly Linked List of Objects
CNSLObject Node of Single Linked List
CNDLObject Node of DoubleyLinked List
CNSLIterator Iterator of Single Linked List
CNDLIterator Iterator of Doubly Linked List
CNStack Stack
CNQueue Abstract Queue Base Class
CNQueueFIFO FIFO Queue
CNQueueLIFO LIFO Queue
CNQueueRandom Random Queue
CNQueueSPT SPT Queue
CNPrioQueueFIFO Priority Queue
CNSink Sink
CNJob Standard Job for Queues
CNDLObject
CNEvent Generic Event
CNNamed
CNEventHandler Abstract Base Class for Event Handlers
CNEventExploder Send Events to multiple EventHandlers
CNEventList List of Events
CNEventBaseSched
CNEventScheduler Event Scheduler
CNEventHeapSched Event Scheduler using a heap
CNSimTime Simulation Time
CNArray Abstract Array Base Class
CNArrayObject Array of Pointer to CNObject
CNArrayChar Array of Char
CNArrayDouble Array of Double
CNArrayFloat Array of Float
CNArrayInt Array of Int
CNArrayLong Array of Long
CNArray2 Base class for 2-dimensional arrays
CNArray2Char Char array class
CNArray2Double double array class
CNArray2Float float array class
CNArray2Int int array class
CNArray2Long long array class
CNArray2Object CNObjPtr array class
CNKey Abstract Base Class for Keys
CNKeyString String Key
CNKeyInt Integer Key
CNHashTable Abstract Hash Table Base Class
CNHashStatic Hash Tables with Static Capacity
CNHashDynamic Hash Tables with Dynamic Capacity
CNHashIterator Sequential Iterator for Hash Tables
CNManager Object Management Frontend
CNCoord 2-Dimensional Coordinates
CNICoord 2-Dimensional Integer Coordinates
CNString Character String
CNFormInt Integer as CNStrings
CNFormFloat Doubles as CNStrings
CNNamed Object with Name
CNIniFile .ini-style config file
CNInt Integer derived from CNObject
CNDouble Double derived from CNObject
CNGetOpt Interface to GNU getopt()
CNRef Base class for classes with reference counting
CNObject
CNRefObj CNObject with reference counting
CNNamed
CNRefNamed CNNamed with reference counting
CNPtr Intelligent pointer to CNRefObjs
CNPipe UNIX Pipe
CNSelect UNIX Select Interface
CNNamed
EZD Base Class for EZD Graphic Objects
EZDDrawing Interface to EZD Drawings
EZDPushButton Interface to EZD Push-Button
EZDWindow Interface to EZD Windows
EZDDiagWin Extra window with x-y diagram
EZDTextWin EZD window for easy text display
EZDObject Interface to EZD Object
EZDDiag x-y diagram as an EZDObject
EZDBlock Block with small rectangles for bit display
EZDPopUp Interface to EZD popup menu
EZDQueue Graphical Representation of a Queue
EZDServer Graphical Representation of a Server
EZDText EZD Object with Text
EZDTimer Graphical Representation of a Timer
CNFClause Clause of a fuzzy rule
CNFRule Fuzzy rule
CNNamed
CNFVar Fuzzy variable
CNFRuleBase Rule base and fuzzy inference engine
CNFSet Fuzzy set abstract base class
CNFSetArray Fuzzy set based on array with membership values
CNFSetLR Fuzzy set with L and R functions
CNFSetTrapez Fuzzy set with trapezium function
CNFSetTriangle Fuzzy set with triangle function
CNFNumTriangle Fuzzy numbers (triangle)
CNReaderTbl Table for adress of reader-function
CNPIO persistent stream Object IO-formatting
CNObject
CNPstream abstract base class for persistent stream class
CNPiostream persistent iostream format
CNPObjectID ID-Managment for persistent classes
CNPInt class persistent CNInt
CNP<type> Other persistent classes
* Menu:
Basic classes:
* CNCL:: CNCL Static Members and Functions
* CNObject:: Root of the CNCL Hierarchy
* CNClass:: Class Description
* CNParam:: Abstract Class for Constructor Parameter Objects
Random Number Generators:
* CNRNG:: Abstract Random Number Generator Base Class
* CNACG:: Additive RNG
* CNFiboG:: Fibonacci RNG
* CNFileG:: Data File RNG
* CNLCG:: Linear Congruence RNG
* CNMLCG:: Multiple Linear Congruence RNG
* CNTausG:: Tausworth RNG
Random Number Distributions:
* CNRndInt:: Random Integers
* CNRandom:: Abstract Random Distribution Base Class
* CNBeta:: Beta Distribution
* CNBinomial:: Binomial Distribution
* CNDeterm:: Deterministic Distribution
* CNDiracTab:: Distribution from Table
* CNDiscUniform:: Discrete Uniform Distribution
* CNErlang:: Erlang-k Distribution
* CNGeometric:: Geometric Distributed Random Numbers
* CNHyperExp:: HyperExp Distributed Random Numbers
* CNHyperGeom:: HyperGeom Distributed Random Numbers
* CNInterTab:: Distribution from Table (Interpolated Values)
* CNLogNormal:: LogNormal Distribution
* CNMDeterm:: Random Mix of Deterministic Distributions
* CNNegExp:: Negative Exponential Distribution
* CNNormal:: Normal Distribution
* CNPoisson:: Poisson Distribution
* CNRandomMix:: Mix of Several `CNRandom' Distributions
* CNRayleigh:: Rayleigh Distribution
* CNRice:: Rice Distribution
* CNTab:: Distribution from Table
* CNUniform:: Uniform Distribution
* CNWeibull:: Weibull Distribution
Statistics:
* CNStatistics:: Abstract Statistics Base Class
* CNMoments:: Evaluation of (Weighted) Moments
* CNMomentsTime:: Evaluation of Time-Weighted Moments
* CNLRE:: Evaluation by LRE
* CNDLRE:: Evaluation by discrete LRE
* CNBatchMeans:: Evaluation by Batch Means
Containers:
* CNAVLTree:: AVL balanced binary search tree
* CNAVLNode:: Node of AVL tree
* CNSLList:: Single Linked List of Objects
* CNSLObject:: Node of Single Linked List
* CNSLIterator:: Iterator of Single Linked List
* CNDLList:: Doubly Linked List of Objects
* CNDLObject:: Node of Doubly Linked List
* CNDLIterator:: Iterator of Doubly Linked List
* CNQueue:: Abstract Queue Base Class
* CNQueueFIFO:: FIFO Queue
* CNQueueLIFO:: LIFO Queue
* CNQueueRandom:: Random Queue
* CNQueueSPT:: SPT Queue
* CNPrioQueueFIFO:: Priority Queue
* CNJob:: Standard Job for Queues
* CNSink:: Sink
* CNStack:: Stack
Events:
* CNEvent:: Generic Event
* CNEventExploder:: Send Events to multiple EventHandlers
* CNEventHandler:: Abstract Base Class for Event Handlers
* CNEventList:: List of Events
* CNEventBaseSched:: Abstract scheduler base class
* CNEventScheduler:: Event Scheduler
* CNEventHeapSched:: Event Scheduler using a heap
* CNSimTime:: Simulation Time
* Event Example:: Example for Event Driven Simulation
Arrays:
* CNArray:: Abstract Array Base Class
* CNArrayObject:: Array of Pointer to CNObject
* CNArrayInt:: Array of Int
* Other CNArray<type>:: Arrays of Other <Type>s
* CNArray2:: Base class for 2-dimensional arrays
* CNArray2Char:: Char array class
* Other CNArray2<type>::Other <Type>s array class
Hash Tables and Object Management:
* CNKey:: Abstract Base Class for Object Management via Keys
* CNKeyString:: Object Management via String Keys
* CNKeyInt:: Object Management via Integer Keys
* CNHashTable:: Abstract Hash Table Class
* CNHashStatic:: Hash Tables with Static Capacity
* CNHashDynamic:: Hash Tables with Dynamic Capacity
* CNHashIterator:: Sequential Iterator for Hash Tables
* CNManager:: Object Management Frontend
Miscellaneous:
* CNCoord:: 2-Dimensional Coordinates
* CNICoord:: 2-Dimensional Integer Coordinates
* CNString:: Character String
* CNNamed:: CNObject with Name
* CNIniFile:: .ini-style config file
* CNFormInt:: Integer as CNStrings
* CNFormFloat:: Doubles as CNStrings
* CNInt:: Integer derived from CNObject
* CNDouble:: Double derived from CNObject
* CNGetOpt:: Interface to GNU getopt()
Unix:
* CNPipe:: Unix Pipe
* CNSelect:: Class interface to select(2) system call
EZD:
* EZD:: Base Class for EZD Graphic Objects
* EZDObject:: Interface to EZD Object
* EZDDrawing:: Interface to EZD Drawings
* EZDPushButton:: Interface to EZD Push-Button
* EZDWindow:: Interface to EZD Windows
* EZDDiagWin:: Extra window with x-y diagram
* EZDTextWin:: EZD window for easy text display
* EZDDiag:: x-y diagram as an EZDObject
* EZDBlock:: Block with small rectangles for bit display
* EZDPopUp:: Interface to EZD popup menu
* EZDQueue:: Graphical Representation of a Queue
* EZDServer:: Graphical Representation of a Server
* EZDText:: EZD Object with Text
* EZDTimer:: Graphical Representation of a Timer
Fuzzy Logic:
* CNFClause:: Clause of a fuzzy rule
* CNFVar:: Fuzzy variable
* CNFRule:: Fuzzy rule
* CNFRuleBase:: Rule base and Fuzzy inference engine
* CNFSet:: Fuzzy set abstract base class
* CNFSetArray:: Fuzzy set based on array with membership values
* CNFSetLR:: Fuzzy set with L and R functions
* CNFSetTrapez:: Fuzzy set with trapezium function
* CNFSetTriangle:: Fuzzy set with triangle function
* CNFNumTriangle:: Fuzzy numbers (triangle)
Persistent:
* CNReaderTbl:: Table for adress of reader-function
* CNPObjectID:: ID-Managment for persistent Objects
* CNPIO:: persistent stream Object IO-formatting
* CNPstream:: abstract base class for persistent stream classes
* CNPiostream:: persistent iostream format
* CNPInt:: class persistent CNInt
* Other CNP<type>:: Other persistent classes
File: cncl.info, Node: Common Functions, Next: CNgenclass, Prev: Class Hierarchy, Up: Introduction
Common CNCL Member Functions
============================
CNCL requires that all classes have a common set of member functions
available. These functions provide runtime type checking and type
information, creation of objects via class descriptions, and safe type
casts.
The common member functions are:
`CNClassDesc CLASS::class_desc() const;'
This function returns a pointer to the class description object,
which must be available for every class in the CNCL hierarchy.
This pointer is used for runtime type information.
`bool CLASS::is_a(CNClassDesc desc) const;'
This function allows runtime type checking. It returns `TRUE' if
the queried object is type compatible with class `desc'.
`void CLASS::print(ostream &strm = cout) const;'
`void CLASS::dump(ostream &strm = cout) const;'
These functions output the object to the given stream `strm'. The
function `print()' is defined in greater detail in the derived
classes. The function `dump()' is intended for debug purposes.
The functions above are defined as pure virtual functions in the
top-level class `CNObject'. They are required in every derived class.
Furthermore the following static member functions are required to
allow object creation via the class description and safe type casts:
`CLASS* CLASS::cast_from_object(CNObject *obj);'
This function does a safe `(CLASS *)' type cast. It checks on type
compatibility between the object passed with the `obj' pointer and
CLASS. If this is a not true, an error message is printed and the
program terminates.
The type checking may be disabled by defining the preprocessor
macro `NO_TYPE_CHECK', e.g. by supplying `-DNO_TYPE_CHECK' on the
compiler's command line.
Example:
XYZ *px; // CNClass XYZ derived from CNObject
ABC *pa; // CNClass ABC derived from CNObject
DEF *pd; // CNClass DEF derived from ABC
CNObject *po;
po = new DEF; // Type compatible (C++ standard)
pd = (DEF *)po; // The traditional way
pd = DEF::cast_from_object(po); // The CNCL way
pa = new DEF;
pd = DEF::cast_from_object(pa); // o.k.
px = XYZ::cast_from_object(pa); // Error
`CNObject *CLASS::new_object(CNParam *param = NIL);'
This function creates an object of type CLASS, optionally passing a
pointer to a parameter object to the constructor.
It is used by the class description `CNClass' to create new
objects.
Every class in CNCL requires a class description object and a pointer
constant pointing to this class description. Following the CNCL
convention, the description object is named CLASS`_desc' and the
pointer is named `CN_'CLASS.
Example:
// Describing object for class XYZ
static CNClass XYZ_desc("XYZ", "$Revision: 0.39 $", XYZ::new_object);
// "Type" for type checking functions
CNClassDesc CN_XYZ = &XYZ_desc;
File: cncl.info, Node: CNgenclass, Next: minmax, Prev: Common Functions, Up: Introduction
`CNgenclass' Script
===================
To generate new classes for the CNCL hierarchy in a convenient way,
the utility `CNgenclass' is provided. It generates a class framework
with all the functions required by CNCL.
Usage:
`CNgenclass' name base
The required parameters are the name of the class to be created and
the name of the base class. The result are two files in the current
directory: name`.h' (class header file) and name`.c' (class
implementation file).
Example:
CNgenclass MyClass CNObject
creates the files `MyClass.h' and `MyClass.c'. Please note that a
leading "`CN'" is removed from the file names.
File: cncl.info, Node: minmax, Prev: CNgenclass, Up: Introduction
`minmax' header file
====================
This header file is copied from the GNU libg++ library. Its min(),
max() definitions are quite useful and appear several times at CNCL. As
minmax is not included with all C++ libraries, this header file is
added to CNCL.
The `inline' min() and the max() functions are declared for
(un-)unsigned char, (un-)signed short, (un-)signed int, (un-)signed
long, float and double.
File: cncl.info, Node: Basic Classes, Next: Random Numbers, Prev: Introduction, Up: Top
The Basic Classes of the CNCL Hierarchy
***************************************
The following classes constitute the basics of CNCL. They provide the
framework for runtime type checking, class descriptions, object
management, and error handling.
* Menu:
* CNCL:: CNCL Static Members and Functions
* CNObject:: Root of the CNCL Hierarchy
* CNClass:: Class Description
* CNParam:: Abstract Class for Constructor Parameter Objects
File: cncl.info, Node: CNCL, Next: CNObject, Up: Basic Classes
CNCL -- CNCL Static Members and Functions
=========================================
SYNOPSIS
--------
`#include <CNCL/CNCL.h>'
TYPE
----
None
* Menu:
BASE CLASSES
------------
DERIVED CLASSES
---------------
* CNObject:: Root of the CNCL Hierarchy
RELATED CLASSES
---------------
DESCRIPTION
-----------
The `CNCL' class contains only static members and functions for the
class library's parameters and error handling. All classes in the CNCL
hierarchy can directly access the static member functions, other code
can call them via `CNCL::'func`()'.
ERROR HANDLING
--------------
The class `CNCL' provides common functionality for error handling.
This is used by all classes to issue an error message or warning and
terminate the program, if desired. The CNCL library also installs a
`matherr()' handler using `CNCL::error()' for displaying an appropiate
error message.
enum ErrorType
{
err_fatal, err_abort, err_warning, err_ignore, err_default, err_info
};
The setting of the CNCL error handling:
`err_abort'
`err_fatal'
Print error message, then terminate the program. (To do so, CNCL
calls the exit handler installed with `set_exit_handler()'.)
`err_abort' is like `err_fatal' but calls `abort()' for
termination resulting in a core dump.
`err_warning'
Print error message with "warning" prefix.
`err_ignore'
No error message.
`err_ignore'
No error, just the message for info.
`err_default'
The default setting of the CNCL error handling. The default is
`err_fatal' (may be set with `set_error()').
The following member functions of `CNCL' can be used to manipulate
the error handling.
`static ErrorType get_error();'
Returns the current error handling type.
`static ErrorType set_error(ErrorType err);'
Sets the error handling type to `err' and returns the previous
value.
`static void set_exit_handler(void (*func)());'
Installs a function to be called on fatal errors. The default
function will print a message and terminate the program by calling
`exit()' (`err_fatal') or `abort()' (`err_abort').
`static void default_exit_handler()'
The CNCL default handler called on fatal errors.
ERROR MESSAGES
--------------
The following member function can be used to output error messages
and/or terminate the program. Each of the functions accepts up to six
`const char *' arguments, if the first one of these is `NIL', then the
default string (`"CNCL error: "', `"CNCL warning: "', `"CNCL: "' for
`err_error'/`err_abort', `err_warning', `err_info', respectively) is
prepended to the output.
`static void error(const char *msg1 = NIL, ...)'
Output error message, default error handling. Up to 6 different
`char *msg'`s can be added.
`void error(ErrorType err, const char *msg1 = NIL, ...)'
Output error message, error handling as specified by `err'.Up to 6
different `char *msg'`s can be added.
`static void fatal(const char *msg1 = NIL, ...)'
Output error message, fatal error handling.Up to 6 different `char
*msg'`s can be added.
`static void warning(const char *msg1 = NIL, ...)'
Output error message, warning error handling.Up to 6 different
`char *msg'`s can be added.
`static void info(const char *msg1 = NIL, ...)'
Output message.Up to 6 different `char *msg'`s can be added.
`static ostream& msg()'
Returns a reference to an output stream. Output to this stream
will be appended to the next `error()', `fatal()', `warning()',
`info()' message. This is actually a `strstream' with a maximum
capacity of `CNCL::STR_BUF_SIZE'.
UTILITIES
---------
Outside the `CNCL' class the following constants and types are
defined:
`NIL'
The null pointer defined as `0'.
`TRUE'
The boolean value true defined as `1'.
`FALSE'
The boolean value false defined as `0'.
`bool'
A boolean data type, actually `typedef int bool'.
File: cncl.info, Node: CNObject, Next: CNClass, Prev: CNCL, Up: Basic Classes
CNObject -- Root of the CNCL Hierarchy
======================================
SYNOPSIS
--------
`#include <CNCL/Object.h>'
TYPE
----
`CN_OBJECT'
* Menu:
BASE CLASSES
------------
* CNCL:: CNCL Static Members and Functions
DERIVED CLASSES
---------------
* CNClass:: Class Description
* CNParam:: Abstract Class for Constructor Parameter Objects
...
RELATED CLASSES
---------------
* CNClass:: Class Description
* CNParam:: Abstract Class for Constructor Parameter Objects
DESCRIPTION
-----------
`CNObject' is the actual base of the CNCL inheritance tree. It must
be supported by all derived classes.
`virtual CNClassDesc class_desc() const;'
Returns the class description (pointer to instance of CNClass) for
runtime type information.
`virtual bool is_a(CNClassDesc desc) const;'
Returns TRUE if the queried object is of type `desc', else FALSE.
`virtual void print(ostream &strm = cout) const = 0;'
Output object to stream.
`virtual void dump(ostream &strm = cout) const = 0;'
Output object to stream for debug purpose.
`virtual int store_on(CNPstream &);'
`virtual int storer(CNPstream &);'
These functions are support functions for persistent objects, so
they are not implemented in all derived classes. They are yielding
a warning if they are called for a non-persistent object.
UTILITIES
---------
`Object.h' defines the following operators for easily writing
objects to streams:
`ostream &operator << (ostream &strm, const CNObject &obj);'
`ostream &operator << (ostream &strm, const CNObject *obj);'
Write object to stream using the `print()' member function. It is
safe to output a null pointer `obj', in this case "`(NIL)'" is
printed.
File: cncl.info, Node: CNClass, Next: CNParam, Prev: CNObject, Up: Basic Classes
CNClass -- Class Description
============================
SYNOPSIS
--------
`#include <CNCL/Class.h>'
TYPE
----
`CN_CLASS'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNObject:: Root of the CNCL Hierarchy
DESCRIPTION
-----------
`CNClass' is used for the type description objects. For each class in
the CNCL hierarchy there is a corresponding object of type `CNClass'.
A pointer to this object is used for the CNCL runtime type information.
Constructors:
`CNClass(char *name, char *version, CNObject *(*func)(CNParam *p));'
The constructor of `CNClass' takes three arguments: the class'
name, the class' version and a pointer to the static
`CLASS::new_object()' member function of classes that provide this
functionality. The function pointer may be `NIL' for classes that
do not provide this, such as abstract base classes.
In addition to the member functions required by CNCL, `CNClass'
provides:
`const char *name() const;'
`const char *get_name() const;'
Returns the class name.
`const char *version() const;'
`const char *get_version() const;'
Returns the class version.
`CNObject *new_object(CNParam *param = NIL) const;'
`CNObject *new_object(Param ¶m) const;'
Creates new objects via the corresponding class' static member
function `new_object()'. The `param' object is used to pass
optional arguments to the constructor.
`static CNClass *cast_from_object(CNObject *obj);'
Safes `(CNClass *)' type cast.
File: cncl.info, Node: CNParam, Next: CNRNG, Prev: CNClass, Up: Basic Classes
CNParam -- Abstract Parameter Base Class
========================================
SYNOPSIS
--------
`#include <CNCL/Param.h>'
TYPE
----
`CN_PARAM'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
...
RELATED CLASSES
---------------
* CNClass:: Class Description
DESCRIPTION
-----------
`CNParam' is the abstract base for parameter classes used to pass
constructor parameters to objects in a general way. This will be used
in the forthcoming CNCL object management.
File: cncl.info, Node: Random Numbers, Next: Evaluation, Prev: Basic Classes, Up: Top
Random Numbers
**************
CNCL provides a variety of random number generators, ranging from the
very simple linear congruence generator to more sophisticated ones. Also
included is a random number generator which reads random data from a
file.
Random numbers are a crucial base of every simulation; most of the
pseudo random number generators included in CNCL have their faults and
short-comings.
The base random number generators are used by the random distribution
classes to generate random numbers with the desired distribution.
* Menu:
Random Number Generators
------------------------
* CNRNG:: Abstract Random Number Generator Base Class
* CNACG:: Additive RNG
* CNFiboG:: Fibonacci RNG
* CNFileG:: Data File RNG
* CNLCG:: Linear Congruence RNG
* CNMLCG:: Multiple Linear Congruence RNG
* CNTausG:: Tausworth RNG
Random Number Distributions
---------------------------
* CNRndInt:: Random Integers
* CNRandom:: Abstract Random Distribution Base Class
* CNBeta:: Beta Distribution
* CNBinomial:: Binomial Distribution
* CNDeterm:: Deterministic Distribution
* CNDiracTab:: Distribution from Table
* CNDiscUniform:: Discrete Uniform Distribution
* CNErlang:: Erlang-k Distribution
* CNGeometric:: Geometric Distributed Random Numbers
* CNHyperExp:: HyperExp Distributed Random Numbers
* CNHyperGeom:: HyperGeom Distributed Random Numbers
* CNInterTab:: Distribution from Table (Interpolated Values)
* CNLogNormal:: LogNormal Distribution
* CNMDeterm:: Random Mix of Deterministic Distributions
* CNNegExp:: Negative Exponential Distribution
* CNNormal:: Normal Distribution
* CNPoisson:: Poisson Distribution
* CNRandomMix:: Mix of Several `CNRandom' Distributions
* CNRayleigh:: Rayleigh Distribution
* CNRice:: Rice Distribution
* CNTab:: Distribution from Table
* CNUniform:: Uniform Distribution
* CNWeibull:: Weibull Distribution
File: cncl.info, Node: CNRNG, Next: CNACG, Prev: CNParam, Up: Random Numbers
CNRNG -- Abstract Random Number Generator Base Class
====================================================
SYNOPSIS
--------
`#include <CNCL/RNG.h>'
TYPE
----
`CN_RNG'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
* CNACG:: Additive RNG
* CNFiboG:: Fibonacci RNG
* CNFileG:: Data File RNG
* CNLCG:: Linear Congruence RNG
* CNMLCG:: Multiple Linear Congruence RNG
* CNTausG:: Tausworth RNG
RELATED CLASSES
---------------
* CNRandom:: Abstract Distribution Base Class
DESCRIPTION
-----------
`CNRNG' is the abstract base class for all CNCL random number
generators. It defines the common interface.
Constructors:
`CNRNG();'
`CNRNG(CNParam *param);'
Initializes `CNRNG'.
In addition to the member functions required by CNCL, `CNRNG'
provides:
`unsigned long as_long();'
This function returns an unsigned integer in the range 0 ...
2^31-1. It uses the as_long32() function from the actual CNRNG to
draw a random number and truncates it down to 31bit.
`virtual unsigned long as_long32() = 0;'
This function is used to draw a random number from the actual CNRNG
(derived from the `CNRNG' class). The result is an unsigned integer
in the range 0 ... 2^32-1 provided the class is able to produce
32bit random numbers.
`virtual bool has_long32() = 0;'
This function tells whether the actual CNRNG is able to produce
32bit integer values or not.
`virtual void reset() = 0;'
Resets the CNRNG to its initial state.
`float as_float();'
`double as_double();'
These functions draw a random number in the range 0 ... 1 and
return the result as a `float' or `double' value.
`virtual void seed(unsigned long s);'
This method for all RNG's only draws `s' as_long32() numbers.
File: cncl.info, Node: CNACG, Next: CNFiboG, Prev: CNRNG, Up: Random Numbers
CNACG -- Additive RNG
=====================
SYNOPSIS
--------
`#include <CNCL/ACG.h>'
TYPE
----
`CN_ACG'
* Menu:
BASE CLASSES
------------
* CNRNG:: Abstract Random Number Generator Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRandom:: Abstract Distribution Base Class
DESCRIPTION
-----------
`CNACG' is the additive random number generator class. This class has
extremly long period lengths and provides a good independence.
Unfortunately, uniformity is not too great.
NOTE: More information about this method you can find at:
Knuth, Donald E.;The Art Of Computer Programming, Volume II; Reading,
Massachusetts; Addison-Wesley; page 26/27
Constructors:
`CNACG(unsigned long seed = 0, int size = 55);'
`CNACG(CNParam *param);'
Initializes `CNACG'.
In addition to the member functions required by CNCL, `CNACG'
provides:
`virtual unsigned long as_long32();'
Draws a random number. The result is an unsigned integer in the
range 0 ... 2^32-1.
`virtual bool has_long32();'
Returns TRUE because the CNACG is able to produce 32bit integer
values.
`virtual void reset();'
Resets the CNACG to its initial state.
File: cncl.info, Node: CNFiboG, Next: CNFileG, Prev: CNACG, Up: Random Numbers
CNFiboG -- Fibonacci RNG
========================
SYNOPSIS
--------
`#include <CNCL/FiboG.h>'
TYPE
----
`CN_FIBOG'
* Menu:
BASE CLASSES
------------
* CNRNG:: Abstract Random Number Generator Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRandom:: Abstract Distribution Base Class
DESCRIPTION
-----------
`CNFiboG' is the Fibonacci random number generator class.
The main advantage of this method can be seen in a combination of a
simple mathematical formula and a period length sufficient enough for
physical simulation runs. Nevertheless, it still represents a pseudo
random number generator. Thus a non-ideal correlation can be expected.
Constructors:
`CNFiboG(CNParam *param);'
`CNFiboG(unsigned long init = 54217137);'
Initializes `CNFiboG' with a 97 elements circular queue and initial
seed.
In addition to the member functions required by CNCL, `CNFiboG'
provides:
`virtual unsigned long as_long32();'
Draws a random number. The result is an unsigned integer in the
range 0 ... 2^32-1.
`virtual bool has_long32();'
Returns TRUE because CNFiboG is able to produce 32bit integer
values.
`virtual void reset();'
Resets the CNFiboG to its initial state.
`void seed_internal(unsigned long *ulp);'
Reinitializes the circular queue and cn with `*ulp', an array of
98 values.
File: cncl.info, Node: CNFileG, Next: CNLCG, Prev: CNFiboG, Up: Random Numbers
CNFileG -- Data File RNG
========================
SYNOPSIS
--------
`#include <CNCL/FileG.h>'
TYPE
----
`CN_FILEG'
* Menu:
BASE CLASSES
------------
* CNRNG:: Abstract Random Number Generator Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRandom:: Abstract Distribution Base Class
DESCRIPTION
-----------
`CNFileG' is a data file random number generator class. It reads
random numbers from a disk file, e.g. data from PURAN2. Thus the quality
of this generator class depends on the quality of the data files. Truely
random numbers can be generated if a good file is supplied. Here the
problem of this class can be seen. A good file must have a sufficient
size. Huge memory use and low speed can be expected when using this
class.
Constructors:
`CNFileG(char *filename, bool par = FALSE);'
`CNFileG(CNParam *param);'
Initializes `CNFileG' with data file `filename' and sets parity
check if required, e.g. parity check for PURAN2.
In addition to the member functions required by CNCL, `CNFileG'
provides:
`virtual unsigned long as_long32();'
Draws a random number. The result is an unsigned integer in the
range 0 ... 2^32-1.
`virtual bool has_long32();'
Returns TRUE because the CNFileG is able to produce 32bit integer
values.
`virtual void reset();'
Resets the CNFileG to its initial state.
`void newfile(char *filename, bool par = FALSE);'
Opens a new file for reading random number data and indicates if
data requires parity check.
`unsigned int wrong_parity();'
Gets the number of wrong parity checks while reading data from a
file, e.g. data from PURAN2.
File: cncl.info, Node: CNLCG, Next: CNMLCG, Prev: CNFileG, Up: Random Numbers
CNLCG -- Linear Congruence RNG
===============================
SYNOPSIS
--------
`#include <CNCL/LCG.h>'
TYPE
----
`CN_LCG'
* Menu:
BASE CLASSES
------------
* CNRNG:: Abstract Random Number Generator Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRandom:: Abstract Distribution Base Class
DESCRIPTION
-----------
`CNLCG' is a linear congruence random number generator class.
This class is using the easiest method for pseudo random number
generator. It is the fastest one, but its short-comings should not be
neglected. The period is very short, usually not sufficient for any
serious simulation. Depending on the chosen seed value only even or odd
numbers are drawn. Any period of drawn numbers are highly correlated.
Thus this class should not be used at any important simulation.
Constructors:
`CNLCG(unsigned long seed = 929);'
`CNLCG(CNParam *param);'
Initializes `CNLCG' with initial `seed'.
In addition to the member functions required by CNCL, `CNLCG'
provides:
`virtual unsigned long as_long32();'
Draws a random number. The result is an unsigned integer in the
range 0 ... 2^31-1.
`virtual bool has_long32();'
Returns FALSE because LCG produces only 31bit integer values.
`virtual void reset();'
Resets the CNLCG to its initial state.
`void seed(unsigned long);'
Sets the CNLCG seed value.
File: cncl.info, Node: CNMLCG, Next: CNTausG, Prev: CNLCG, Up: Random Numbers
CNMLCG -- Multiple Linear Congruence RNG
========================================
SYNOPSIS
--------
`#include <CNCL/MLCG.h>'
TYPE
----
`CN_CNMLCG'
* Menu:
BASE CLASSES
------------
* CNRNG:: Abstract Random Number Generator Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRandom:: Abstract Distribution Base Class
DESCRIPTION
-----------
`CNMLCG' is a multiple linear congruence random number generator
class combining the results of two different CNLCGs.
Constructors:
`CNMLCG();'
`CNMLCG(long seed1, long seed2);'
`CNMLCG(CNParam *param);'
Initializes `CNMLCG' with two seeds, `seed1' and `seed2'. The
default constructor sets both seeds to 0.
In addition to the member functions required by CNCL, `CNMLCG'
provides:
`virtual unsigned long as_long32();'
Draws a random number. The result is an unsigned integer in the
range 0 ... 2^31-1.
`virtual bool has_long32();'
Returns FALSE because CNMLCG produces only 31bit intger values.
`virtual void reset();'
Resets the CNMLCG to its initial state.
`void seed(unsigned long s);'
Sets the two seed values, the first one to `s' and the second one
to `s + 2147483561'.
`void seed_internal(unsigned long, unsigned long);'
Sets both seed values.
File: cncl.info, Node: CNTausG, Next: CNRndInt, Prev: CNMLCG, Up: Random Numbers
CNTausG -- Tausworth RNG
=========================
SYNOPSIS
--------
`#include <CNCL/TausG.h>'
TYPE
----
`CN_TAUSG'
* Menu:
BASE CLASSES
------------
* CNRNG:: Abstract Random Number Generator Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRandom:: Abstract Distribution Base Class
DESCRIPTION
-----------
`CNTausG' is a Tausworth random number generator class.
This generator is a special form of the Fibonacci generator. The
period length is reduced, but the mathematical formula is easier. It
even can be implemented as a hardware shift register. Binomial
Distribution Constructors:
`CNTausG();'
`CNTausG(CNParam *param);'
Initializes `CNTausG'.
In addition to the member functions required by CNCL, `CNTausG'
provides:
`virtual unsigned long as_long32();'
Draws a random number. The result is an unsigned integer in the
range 0 ... 2^32-1.
`virtual bool has_long32();'
Returns TRUE because CNTausG is able to produce 32bit integer
values.
`virtual void reset();'
Resets the CNTausG to its initial state.
File: cncl.info, Node: CNRndInt, Next: CNRandom, Prev: CNTausG, Up: Random Numbers
CNRndInt -- Random Integers
===========================
SYNOPSIS
--------
`#include <CNCL/RndInt.h>'
TYPE
----
`CN_RNDINT'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRNG:: Abstract Random Number Generator Base Class
DESCRIPTION
-----------
`CNRndInt' generates uniform distributed random integers in a given
interval. The result is the same as provided by the `CNDiscUniform'
distribution, but `CNRndInt' is more efficient.
BEWARE: do NOT use the `CNLCG' RNG as a base generator for
`CNRndInt'.
Constructors:
`CNRndInt();'
`CNRndInt(CNParam *param);'
`CNRndInt(long low, long high, CNRNG *gen);'
`CNRndInt(long high, CNRNG *gen);'
`CNRndInt(CNRNG *gen);'
Initializes a `CNRndInt' with base RNG `gen' and upper/lower
interval limits `low'/`high'.
In addition to the member functions required by CNCL, `CNRndInt'
provides:
`CNRNG *generator() const;'
`CNRNG *generator(CNRNG *gen);'
Gets/sets the base CNRNG used by `CNRndInt'.
`long low() const;'
`long high() const;'
`long low(long x);'
`long high(long x);'
Gets/sets the upper/lower interval limits.
`long operator()();'
`long operator()(long high);'
`long operator()(long low, long high);'
`long as_long();'
`long as_long(long high);'
`long as_long(long low, long high);'
Draws a `long' random integer. Interval limits may be passed as
optional parameters.
`int as_int();'
`int as_int(long high);'
`int as_int(long low, long high);'
Draws a `int' random integer. Interval limits may be passed as
optional parameters.
File: cncl.info, Node: CNRandom, Next: CNBeta, Prev: CNRndInt, Up: Random Numbers
CNRandom -- Abstract Random Distribution Base Class
===================================================
SYNOPSIS
--------
`#include <CNCL/Random.h>'
TYPE
----
`CN_RANDOM'
* Menu:
BASE CLASSES
------------
* CNObject:: Root of the CNCL Hierarchy
DERIVED CLASSES
---------------
* CNRandom:: Abstract Random Distribution Base Class
* CNBeta:: Beta Distribution
* CNBinomial:: Binomial Distribution
* CNDeterm:: Deterministic Distribution
* CNDiracTab:: Distribution from Table
* CNDiscUniform:: Discrete Uniform Distribution
* CNErlang:: Erlang-k Distribution
* CNGeometric:: Geometric Distributed Random Numbers
* CNHyperExp:: HyperExp Distributed Random Numbers
* CNHyperGeom:: HyperGeom Distributed Random Numbers
* CNInterTab:: Distribution from Table (Interpolated Values)
* CNLogNormal:: LogNormal Distribution
* CNMDeterm:: Random Mix of Deterministic Distributions
* CNNegExp:: Negative Exponential Distribution
* CNNormal:: Normal Distribution
* CNPoisson:: Poisson Distribution
* CNRandomMix:: Mix of Several `CNRandom' Distributions
* CNRayleigh:: Rayleigh Distribution
* CNRice:: Rice Distribution
* CNTab:: Distribution from Table
* CNUniform:: Uniform Distribution
* CNWeibull:: Weibull Distribution
RELATED CLASSES
---------------
* CNRNG:: Abstract Random Number Generator Base Class
DESCRIPTION
-----------
`CNRandom' is the abstract base class for all CNCL random number
distributions. It defines a common interface to access to all derived
RNG classes in a common way.
Constructors:
`CNRandom(CNRNG *gen);'
`CNRandom(CNParam *param);'
Initializes `CNRandom' with a base random number generator.
In addition to the member functions required by CNCL, `CNRandom'
provides:
`CNRNG *generator();'
Returns a pointer to the actually used CNRNG.
`void generator(CNRNG *gen);'
Sets the CNRNG used by `CNRandom' to `gen'.
`virtual double operator() () = 0;'
`double draw();'
Draws a random number from the distribution. The operator `()'
must be defined in the derived classes.
File: cncl.info, Node: CNBeta, Next: CNBinomial, Prev: CNRandom, Up: Random Numbers
CNBeta -- Beta Distribution
===========================
SYNOPSIS
--------
`#include <CNCL/Beta.h>'
TYPE
----
`CN_BETA'
* Menu:
BASE CLASSES
------------
* CNRandom:: Abstract Random Distribution Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRNG:: Abstract Random Number Generator Base Class
DESCRIPTION
-----------
`CNBeta' is a class for generating beta distributed random numbers.
Constructors:
`CNBeta();'
`CNBeta(CNParam *param);'
`CNBeta(long a, long b, CNRNG *gen);'
Initializes a `CNBeta' distribution with a base random number
generator `gen' and the parameters `a' and `b'.
In addition to the member functions required by CNCL, `CNBeta'
provides:
`virtual double operator() ();'
Draws a beta distributed random number.
File: cncl.info, Node: CNBinomial, Next: CNDeterm, Prev: CNBeta, Up: Random Numbers
CNBinomial -- Binomial Distribution
===================================
SYNOPSIS
--------
`#include <CNCL/Binomial.h>'
TYPE
----
`CN_BINOMIAL'
* Menu:
BASE CLASSES
------------
* CNRandom:: Abstract Random Distribution Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRNG:: Abstract Random Number Generator Base Class
DESCRIPTION
-----------
`CNBinomial' is a class for generating binomial distributed random
numbers.
Constructors:
`CNBinomial();'
`CNBinomial(CNParam *param);'
`CNBinomial(int n, double u, CNRNG *gen);'
Initializes a `CNBinomial' distribution with a base random number
generator `gen', and the parameters `n' and `u'.
In addition to the member functions required by CNCL, `CNBinomial'
provides:
`int n();'
`int n(int xn);'
`double u();'
`double u(double xu);'
Gets/sets the values for n and u.
`virtual double operator() ();'
Draws a binomial distributed random number.
File: cncl.info, Node: CNDeterm, Next: CNDiracTab, Prev: CNBinomial, Up: Random Numbers
CNDeterm -- Deterministic Distribution
======================================
SYNOPSIS
--------
`#include <CNCL/Determ.h>'
TYPE
----
`CN_DETERM'
* Menu:
BASE CLASSES
------------
* CNRandom:: Abstract Random Distribution Base Class
DERIVED CLASSES
---------------
RELATED CLASSES
---------------
* CNRNG:: Abstract Random Number Generator Base Class
DESCRIPTION
-----------
`CNDeterm' is a class for generating deterministic "random" numbers,
i.e. it always generates the same value. This is useful for mixed
distributions.
Constructors:
`CNDeterm();'
`CNDeterm(CNParam *param);'
`CNDeterm(double value, CNRNG *gen);'
Initializes a `CNDeterm' distribution with `value'.
In addition to the member functions required by CNCL, `CNDeterm'
provides:
`double value();'
`double mean();'
`double value(double x);'
`double mean(double x);'
Gets/sets the deterministic value.
`virtual double operator() ();'
Draws a deterministic (i.e. not random) number.